package com.lx.testelk.api;

import com.lx.testelk.Constants.ELKMsgConstants;
import com.lx.testelk.Enums.ELKMsgCodeEnums;
import com.lx.testelk.Enums.ELKMsgTypeEnums;
import com.lx.testelk.aspect.WebLogAspect;
import com.lx.testelk.entity.ELKMessage;
import lombok.extern.java.Log;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TODO
 *
 * @Description
 * @Author Lx
 * @Date 2024/7/29 16:51
 **/


@RequestMapping("/ELK")
@RestController
public class testELKController {
    private static final Logger LOGGER = LoggerFactory.getLogger(WebLogAspect.class);

    @GetMapping("/hello")
    public String hello(){
//         ELKMessage msg = new ELKMessage().builder()
//                .Type(ELKMsgTypeEnums.ERROR.getValue())
////                .Errorcode(ELKMsgCodeEnums.ERROR.getValue())
//                .msg("日志信息测试------------------")
//                .build();


//        String s = msg.toString();
//        System.out.println(s);
//        LOGGER.info("---------------INFO信息---------------");
//        LOGGER.error("---------------ERROR信息---------------");
        System.out.println("hello~~");
//        throw new AppletIOException(code,info)
        return "hello";
    }


    @RequestMapping("/getById")
    @Trace//在需要获取TraceId的代码上添加该注解
    public Integer getById(Integer sId){

        String id = TraceContext.traceId();
        return Integer.valueOf(id);
    }

}
